package net.sh.dpinfrastructure.log;

import org.slf4j.LoggerFactory;
import org.slf4j.spi.LocationAwareLogger;
import org.springframework.stereotype.Service;


/**
 * 
 * 常用日志类
 * 
 * @version 1.0
 * @since JDK1.7
 * @author shaohui
 * @company 上海朝阳永续信息技术有限公司
 * @copyright (c) 2015 SunTime Co'Ltd Inc. All rights reserved.
 * @date 2015年8月18日 上午9:12:40
 */
@Service("dpLogger")
public class DPLogger{
    
    private LocationAwareLogger logger;

    private static final String FQCN = DPLogger.class.getName();

    public DPLogger() {
        logger = (LocationAwareLogger) LoggerFactory.getLogger(DPLogger.class);
    }
    
    public DPLogger(String loggerName) {
        logger = (LocationAwareLogger) LoggerFactory.getLogger(loggerName);
    }
    
    public DPLogger(Class<?> clazz) {
        logger = (LocationAwareLogger) LoggerFactory.getLogger(clazz);
    }
    
    public void trace(String msg) {
        logger.log(null, FQCN, LocationAwareLogger.TRACE_INT, msg, null, null);
    }

    public void debug(String msg) {
        logger.log(null, FQCN, LocationAwareLogger.DEBUG_INT, msg, null, null);
    }

    public void info(String msg) {
        logger.log(null, FQCN, LocationAwareLogger.INFO_INT, msg, null, null);
    }

    public void warn(String msg) {
        logger.log(null, FQCN, LocationAwareLogger.WARN_INT, msg, null, null);
    }

    public void warn(String msg, Throwable exception) {
        logger.log(null, FQCN, LocationAwareLogger.WARN_INT, msg, null, exception);
    }

    public void error(String msg) {
        logger.log(null, FQCN, LocationAwareLogger.ERROR_INT, msg, null, null);
    }

    public void error(String msg, Throwable exception) {
        logger.log(null, FQCN, LocationAwareLogger.ERROR_INT, msg, null, exception);
    }

    public void fatal(String msg) {
        logger.log(null, FQCN, LocationAwareLogger.ERROR_INT, msg, null, null);
    }

    public void trace(String msg, Object... objs) {
        logger.log(null, FQCN, LocationAwareLogger.TRACE_INT, msg, objs, null);
    }

    public void debug(String msg, Object... objs) {
        logger.log(null, FQCN, LocationAwareLogger.DEBUG_INT, msg, objs, null);
    }

    public void info(String msg, Object... objs) {
        logger.log(null, FQCN, LocationAwareLogger.INFO_INT, msg, objs, null);
    }

    public void warn(String msg, Object[] objArray) {
        logger.log(null, FQCN, LocationAwareLogger.WARN_INT, msg, objArray, null);
    }

    public void warn(String msg, Object[] objArray, Throwable e) {
        logger.log(null, FQCN, LocationAwareLogger.WARN_INT, msg, objArray, e);
    }

    public void error(String msg, Object[] objArray) {
        logger.log(null, FQCN, LocationAwareLogger.ERROR_INT, msg, objArray, null);
    }

    public void error(String msg, Object[] objArray, Throwable e) {
        logger.log(null, FQCN, LocationAwareLogger.ERROR_INT, msg, objArray, e);
    }

    public void fatal(String msg, Throwable exception) {
        logger.log(null, FQCN, LocationAwareLogger.ERROR_INT, msg, null, exception);
    }
}
